package com.interauto.Dao.Mapper;

import com.interauto.Dao.entity.Runtasktable;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 处理任务表相关的sql
 */
@Mapper
public interface MgRunTaskInter {

    @Insert("insert into runtasktable(projectid, taskname, taskstatus, runcycle, caseinfo, callnumber, callemail, delstatus, createtime, updatetime) " +
            "VALUE (#{param.projectid},#{param.taskname},2,#{param.runcycle},#{param.caseinfo},#{param.callnumber},#{param.callemail},0,now(),now())")
    void addruntask(@Param(value = "param") Runtasktable runtasktable);

    @Update("update runtasktable set delstatus=1 where id=#{id}")
    void delruntask(@Param(value = "id") int id);

    @Update("update runtasktable set taskname=#{param.taskname},runcycle=#{param.runcycle},caseinfo=#{param.caseinfo}," +
            "callnumber=#{param.callnumber},callemail=#{param.callemail},updatetime=now() where id=#{param.id}")
    void upruntask(@Param(value = "param") Runtasktable runtasktable);

    @Update("update runtasktable set taskstatus=#{status} where id=#{id}")
    void upstatusruntask(@Param(value = "id") int id,@Param(value = "status") int status);

    @Select("select * from runtasktable where projectid=#{projectid} and delstatus=0")
    List<Runtasktable> getRuntasksforProjectid(@Param(value = "projectid") int projectid);

    @Select("select * from runtasktable where delstatus=0 and taskstatus=1")
    List<Runtasktable> getGoRuntasks();

    @Select("select * from runtasktable where id=#{id}")
    Runtasktable getRuntasktable(@Param(value = "id") int id);
}
